package com.zyx.flinkdemo.stream.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author Yaxi.Zhang
 * @since 2021/4/25 12:08
 * desc: 获取配置文件
 */
@Slf4j
public class PropUtil {
    public static Properties getProperties(String propName) {
        InputStream resourceAsStream = PropUtil.class.getClassLoader().getResourceAsStream(propName);
        Properties properties = new Properties();
        try {
            properties.load(resourceAsStream);
        } catch (IOException e) {
            e.printStackTrace();
            log.error("++++++++++++++++++++ {} 配置读取失败", propName);
        } finally {
            if (resourceAsStream != null) {
                try {
                    resourceAsStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                    log.info("++++++++++++++++++++ {} 关闭失败", propName);
                }
            }
        }
        return properties;
    }
}